package WaitNotify.demo3;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: sfx
 * Date: 2022-12-25
 * Time: 17:47
 */
//人是一个线程->用来接收信
public class People extends Thread {

    @Override
    public void run() {
        System.out.println("开始收信");
        GuardedObject guardedObject = MailBox.CreateGuardedObject();
        try {
            //最多等待3s
            String mail = (String) guardedObject.get(3000);
            System.out.printf("收信的信息id : %d,mail : %s\n",guardedObject.getId(),mail);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
    }
}
